package com.dayu.other.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.dayu.common.utils.DateUtils;
import com.dayu.common.utils.SecurityUtils;
import org.springframework.stereotype.Service;
import com.dayu.other.mapper.DyJudgeObligationMapper;
import com.dayu.other.domain.DyJudgeObligation;
import com.dayu.other.service.IDyJudgeObligationService;

import javax.annotation.Resource;

/**
 * 判责中心Service业务层处理
 *
 * @author HK
 * @date 2024-01-24
 */
@Service
public class DyJudgeObligationServiceImpl implements IDyJudgeObligationService
{
    @Resource
    private DyJudgeObligationMapper dyJudgeObligationMapper;

    /**
     * 查询判责中心
     *
     * @param id 判责中心ID
     * @return 判责中心
     */
    @Override
    public DyJudgeObligation selectDyJudgeObligationById(Long id)
    {
        return dyJudgeObligationMapper.selectDyJudgeObligationById(id);
    }

    /**
     * 查询判责中心列表
     *
     * @param dyJudgeObligation 判责中心
     * @return 判责中心
     */
    @Override
    public List<DyJudgeObligation> selectDyJudgeObligationList(DyJudgeObligation dyJudgeObligation)
    {
        return dyJudgeObligationMapper.selectDyJudgeObligationList(dyJudgeObligation);
    }

    @Override
    public Map<String, Object> queryListPrice(DyJudgeObligation obligation) {
        Map<String, Object> map = new HashMap<>();
        map.put("price", dyJudgeObligationMapper.queryListPrice(obligation));
        return map;
    }

    /**
     * 新增判责中心
     *
     * @param dyJudgeObligation 判责中心
     * @return 结果
     */
    @Override
    public int insertDyJudgeObligation(DyJudgeObligation dyJudgeObligation)
    {
        dyJudgeObligation.setCrateTime(new Date());
        dyJudgeObligation.setCreateBy(SecurityUtils.getUsername());
        return dyJudgeObligationMapper.insertDyJudgeObligation(dyJudgeObligation);
    }

    /**
     * 修改判责中心
     *
     * @param dyJudgeObligation 判责中心
     * @return 结果
     */
    @Override
    public int updateDyJudgeObligation(DyJudgeObligation dyJudgeObligation)
    {
        dyJudgeObligation.setUpdateTime(DateUtils.getNowDate());
        return dyJudgeObligationMapper.updateDyJudgeObligation(dyJudgeObligation);
    }

    @Override
    public List<DyJudgeObligation> workQueryList() {
        DyJudgeObligation bo = new DyJudgeObligation();
        bo.setJudgeUserId(SecurityUtils.getLoginUser().getUser().getUserId());
        bo.setHasState(0);
        bo.setStatus(0);
        return dyJudgeObligationMapper.selectDyJudgeObligationList(bo);
    }
}
